// class FooReplacer {
//   static[Symbol.replace](target, replacement) {
//     console.log(target.split('foo'))
//     return target.split('foo').join(replacement)
//   }
// }
// console.log('barfoobaz'.replace(FooReplacer,'qux'))

// class StringReplcer {
//   constructor(str) {
//     this.str = str
//   }
//   [Symbol.replace](target, replacement) {
//     return target.split(this.str).join(replacement)
//   }
// }
// console.log('barfoobaz'.replace(new StringReplcer('foo'),'qux'))

class CustomArray extends Array {
  static get [Symbol.species]() {
    return Array; // 在这里指定衍生数组实例应使用的构造函数
  }
}

const originalArray = [1, 2, 3];
const customArray = new CustomArray(...originalArray);

const mappedArray = customArray.map(num => num * 2);
// console.log(mappedArray instanceof CustomArray); // false
// console.log(mappedArray instanceof Array); // true

const fun = function fun() {}

// console.log(Object.prototype.toString.call(fun))

class Foo {}
let foo = new Foo()